﻿personDataService = (function () {
    "use strict";

    function get(query) {
        return $.ajax({
            type: "GET",
            url: settings.personsApiUrl,
            data: query            
        });
    }    

    function add(person) {
        return $.ajax({
            type: "POST",
            url: settings.personsApiUrl,
            data: JSON.stringify(person)            
        });
    }

    function edit(person) {
        return $.ajax({
            type: "PUT",
            url: settings.personsApiUrl + "/" + person.id,
            data: JSON.stringify(person)            
        });
    }

    function remove(id) {
        return $.ajax({
            type: "DELETE",
            url: settings.personsApiUrl + "/" + id,
            data: id            
        });
    }

    return {
        get: get,
        add: add,
        edit: edit,
        remove: remove
    }
})();